package database;

import java.util.NoSuchElementException;

/*
 * The Dictionary class provides a simplified interface for
 * implementations of abstract data types which map keys to values.
 * Each key is associated with at most one value.
 * 
 * Given a Dictionary and a key, the associated value can be looked
 * up provided they are non-null. 
 *
 * Keys are Comparable objects.
 * 
 * The iterator returns dictionary-entries in ascending order by key.
 * 
 * <K> is type for the comparable key element
 * <V> is type for the associated value element
 */
public interface Dictionary<K extends Comparable<K>, V> 
extends Iterable<DictionaryEntry<K, V>> {

	// Returns the number of key-value objects stored in this dictionary.
	public int size();

	// Tests if this Dictionary contains no key-value objects.
	public boolean isEmpty();

	/*
	 * Returns the value associated with the key. There
	 * can be at most one value associated with each key.
	 * 
	 * throws NoSuchElementException if the specified key does not exist in 
	 * the dictionary.
	 */
	public V get(K key) throws NoSuchElementException;

	/*
	 * Creates a dictionary entry associating the given key and
	 * value. If the dictionary previously contained an entry for 
	 * this key, the old value is updated with the given value.
	 */
	public void put(K key, V value);

	/*
	 * Removes the entry for the key from the dictionary if it is present.
	 * 
	 * throws NoSuchElementException if it is not present
	 */
	public void remove(K key) throws NoSuchElementException;

	// Removes all entries from the dictionary.
	public void clear();

}
